package NWish.properties.object3ds
{
	import NWish.json.OrderDict;
	import NWish.properties.animator.SmoothSkeletonAnimatorProperties;
	
	import away3d.animators.SmoothSkeletonAnimator;
	import away3d.animators.data.SkeletonAnimationState;
	import away3d.containers.Scene3D;

	public class AnimatorProperties
	{
		private var _parent;
		
		
		public function AnimatorProperties(parent)
		{
			_parent = parent;
		}
		
		public function propertiesToDict(obj,dict:OrderDict,read_only,saving = false)
		{
			if(read_only == false)
			{
				if(saving)
				{
					if(SmoothSkeletonAnimatorProperties.hasAnimactor(obj))
						new SmoothSkeletonAnimatorProperties(_parent).save(obj,dict);
				}
				else
				{
					if(SmoothSkeletonAnimatorProperties.hasAnimactor(obj))
						new SmoothSkeletonAnimatorProperties(_parent)
							.simplePropertiesToDict(obj,dict);
				}
			}
		}
		
		public function dictToProperties(dict,obj,scene:Scene3D,isloading)
		{
			var animDict = SmoothSkeletonAnimatorProperties.getAnimactorDict(dict)
			if(animDict)
			{
				obj.extra.smoothSkeletonAnimator 
					= new SmoothSkeletonAnimator(SkeletonAnimationState(obj.animationState));
				new SmoothSkeletonAnimatorProperties(_parent).dictToProperties(animDict,obj,scene,isloading);
			}
			
		}
	}
}